<%@ page contentType="text/html; charset=utf-8" language="java"
	import="java.sql.*" errorPage=""%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>blog</title>
		<style type="text/css">
<!--
body {
	background-image: url("image/background.jpg");
}
-->
</style>
	</head>

	<body>
		<div>
			您好：
			<s:property value="#session.user.name" />
			&nbsp;
			<a href="manage.action">管理博客</a>&nbsp;
			<a href="logout.action">退出</a>
			<div align="right">
				<form action="query.action" method="post">
					<input type="text" name="name">
					<select name="type">
						<option value="1">
							用户名
						</option>
						<option value="2">
							博文
						</option>
						<option value="3">
							相册
						</option>
					</select>
					<input type="submit" value="搜索">
				</form>
			</div>
		</div>
		<div align="center">
			<a
				href="viewUser.action?user.id=<s:property value="#request.user.id"/>">首页</a>|
			<a
				href="viewArticles.action?user.id=<s:property value="#request.user.id"/>&classid=0">日志</a>
			|
			<a
				href="viewAlbums.action?user.id=<s:property value="#request.user.id"/>">相册|</a>
			<a
				href="viewMessages.action?user.id=<s:property value="#request.user.id"/>">留言</a>
		</div>

		<br />
		<s:property value="#request.user.name"></s:property>
		的博客
		<div>
			<img src='<s:property value="#request.user.image"/>' height="50px"
				width="50px">
		</div>
		</div>
		<br />

		<div align="center">
			日志
			<br />

			<table border="1" width="400px;">
				<s:iterator value="#request.user.articles" begin="0" end="5">
					<tr>
						<td>
							<a href="viewArticle.action?article.id=<s:property value="id"/>"><s:property
									value="title" /> </a>
							<br />
							<s:property value="content" />
						</td>
					</tr>
				</s:iterator>
				<s:if test="%{#request.user.articles.size==0}">
					<tr>
						<td>
							暂无日志
						</td>
					</tr>
				</s:if>
				<s:else>
					<tr>
						<td>
							<a
								href="viewArticles.action?user.id=<s:property value="#request.user.id"/>&classid=0">查看全部</a>
						</td>
					</tr>
				</s:else>
			</table>
		</div>
		<div align="center">
			留言
			<br />

			<table border="1" width="400px;">
				<s:iterator value="#request.user.messages" begin="0" end="5">
					<tr>
						<td>
							<a href="viewUser.action?user.id=<s:property value="leaver.id"/>"><s:property
									value="leaver.name" /> </a>
							<br />
							<s:property value="message" />
						</td>
					</tr>
				</s:iterator>
				<s:if test="%{#request.user.message.size==0}">
					<tr>
						<td>
							暂无留言
						</td>
					</tr>
				</s:if>
				<s:else>
					<tr>
						<td align="center">
							<a 
								href="viewMessages.action?user.id=<s:property value="#request.user.id"/>">查看全部</a>
						</td>
					</tr>
				</s:else>

				<tr>
					<td align="center">
						<div style="color: red">
							<s:fielderror />
						</div>
						<form action="leaveMessage.action" method="post">
							<input type="hidden" name="message.user.id"
								value="<s:property value="#request.user.id"/>" />
							<input type="hidden" name="message.leaver.id"
								value="<s:property value="#session.user.id"/>">
							<textarea name="message.message" style="width: 300px;height: 100px;"></textarea>
							<br>
							<input type="submit" value="发表留言">
						</form>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>
